// 手牌一
class playRadio extends eui.Component{
    private maskobj:eui.Image;
    private contentBg:egret.Sprite = new egret.Sprite();
    public constructor(){
        super();
        this.once(eui.UIEvent.COMPLETE,this.onComplete,this);
        this.skinName = "src/Game/gameRoom/chat/playRadioSkin.exml";
    }
    private onComplete(){
        this.addChild(this.contentBg);
        this.contentBg.mask = this.maskobj;
        this.contentBg.x = this.maskobj.x;
        this.contentBg.y = this.maskobj.y;
        this.contentBg.addChild(this.txtobj);
        this.touchEnabled = false;
        this.touchChildren = false;
        this.visible = false; 
    }

    private stringData:Array<any> = new Array();    
    public setContent(_data:any){   
        this.visible = true;    
        for(var i=0;i<_data.length;i++){
            this.stringData.push(_data[i]);
        }
        this.toEffect();
    }
    private currentInt:number = 0;
    private playComplete:Boolean = true;//播放完成
    private txtobj:egret.TextField = new egret.TextField();
    private toEffect(){
        if(this.stringData.length>0&&this.playComplete){
            let str:string = String(this.stringData[0]);
            this.playComplete = false;
            this.txtobj.y = 4;
            this.txtobj.size = 26;
            this.txtobj.multiline = false;
            this.txtobj.width = 28*str.length
            this.txtobj.text = str;
            this.txtobj.width = this.txtobj.textWidth+(2*str.length);
            this.txtobj.x = this.maskobj.width;
        egret.Tween.get(this.txtobj).to({x:-this.txtobj.width},8000+(str.length*150)).call(()=>{
            egret.Tween.removeTweens(this.txtobj);
            this.stringData.splice(0,1);
            if(this.stringData.length>0){
                this.playComplete = true;
                this.toEffect();
            }else{
                //alert("播放完成");
                this.playComplete = true;
                this.visible = false;
            }
        },this);
        }
    }
}